<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/base/jsp/common/Taglibs.jsp"%>
<%@ include file="/base/jsp/common/CustomTheme.jsp"%><%
response.setHeader("pragma","no-cache");
response.setHeader("cache-control","no-cache");
response.setHeader("expires","0");%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>组织机构管理</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link href="${ctx}/base/css/base.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/base/css/common.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/base/css/${customTheme}.css" rel="stylesheet" type="text/css" />

<script src="${ctx}/base/js/jquery/jquery.js" type="text/javascript"></script>
<script src="${ctx}/base/js/common/FormFunction.js" type="text/javascript"></script><!-- 鍏敤鐨勬寜閽嚱鏁� -->
<script type="text/javascript">
function checkStaff(val,name) {
    var selectType = $("#selectType").val();
    if(selectType=='single') {
        $("#selectedStaff").attr("value", $(val).val());
        $("#selectedStaffName").attr("value", name);
    }else if(selectType=='multi') {
		var originalSelected = $("#selectedStaff").val();
		var originalSelectedName = $("#selectedStaffName").val();
		
		var selectedStaff = $(val).val();
		var selectedStaffName = name;
		var newSelected = "";
		var newSelectedName = "";
		if($(val).attr("checked")){
			if(originalSelected !="") {
				newSelected = originalSelected + "," + selectedStaff ;
				newSelectedName = originalSelectedName + "," + selectedStaffName;
			} else {
				newSelected = selectedStaff;
				newSelectedName = selectedStaffName;
			}
		} else {
			var selectedArray = originalSelected.split(",");
			for(var count=0; count<selectedArray.length; count++){
				if(selectedStaff == selectedArray[count]) {
					selectedArray[count] = null;
					break;
				}
			}
			for(var i=0; i<selectedArray.length; i++){
				if(selectedArray[i]) {
					newSelected +=  selectedArray[i] + ",";
				}
			}
			newSelected = newSelected.substring(0,newSelected.length-1);
			
			var selectedNameArray = originalSelectedName.split(",");
			for(var count=0; count<selectedNameArray.length; count++){
				if(selectedStaffName == selectedNameArray[count]) {
					selectedNameArray[count] = null;
					break;
				}
			}
			for(var i=0; i<selectedNameArray.length; i++){
				if(selectedNameArray[i]) {
					newSelectedName +=  selectedNameArray[i] + ",";
				}
			}
			newSelectedName = newSelectedName.substring(0,newSelectedName.length-1);
		}
		$("#selectedStaff").attr("value", newSelected);
		$("#selectedStaffName").attr("value", newSelectedName);
	}
}

$(document).ready(function() {
    $("#selectedStaff").val(opener.document.getElementById("<s:property value='valueInputId'/>").value);
    $("#selectedStaffName").val(opener.document.getElementById("<s:property value='textInputId'/>").value);
});
</script>
</head>
<body style="overflow-x:hidden;overflow-y:hidden;border: none;marin:0px;"><!-- onblur="window.focus();" -->
<form id="orgPosStaffMainForm">
<s:hidden name="selectType"/>
<s:hidden name="returnType"/>
<s:hidden name="selectedStaff"/>
<s:hidden name="selectedStaffName"/>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="1">
  <tr>
    <td width="260" height="100%">
      <IFRAME width="100%" height="100%" frameBorder="1" frameSpacing="0" src="${ctx}/sys/users!showOrganizationTree.action?parentId=<s:property value='organization.id'/>" NAME="tree" id="tree"></IFRAME>
    </td>
    <td height="100%">
      <IFRAME width="100%" height="100%" frameBorder="1" frameSpacing="0" src="${ctx}/sys/users!listSelect.action?selectType=<s:property value="selectType"/>&returnType=<s:property value="returnType"/>&orgId=<s:property value='organization.id'/>" NAME="content" id="content"></IFRAME>
    </td>
  </tr>
  <tr>
    <td colspan="2" align="center" height="60">
        <input type="button" onClick="javascript:setStaffSelectValue();" id="selectStaff" value="选择" class="btn2" />
        <input type="button" name="closeWin" class="btn2" value="取消" onClick="javascript:window.close();">
    </td>
  </tr>
</table>
</form>
<script language="JavaScript">
function setStaffSelectValue() {
    opener.document.getElementById("<s:property value='valueInputId'/>").value = $("#selectedStaff").val();
    opener.document.getElementById("<s:property value='textInputId'/>").value = $("#selectedStaffName").val();
    window.close();
}
</script>
</body>
</html>